<template>
    <a-drawer
        :title="formData.workflowMessagesId ? '编辑待办' : '增加待办'"
        :width="600"
        :visible="visible"
        :destroy-on-close="true"
        :footer-style="{ textAlign: 'right' }"
        @close="onClose"
    >
        <a-form ref="formRef" :model="formData" :rules="formRules" layout="vertical">
            <a-form-item label="MESSAGE_WORKITEM_ID：" name="messageWorkitemId">
                <a-input v-model:value="formData.messageWorkitemId" placeholder="请输入MESSAGE_WORKITEM_ID" allow-clear />
            </a-form-item>
            <a-form-item label="MESSAGE_TRACK_ID：" name="messageTrackId">
                <a-input v-model:value="formData.messageTrackId" placeholder="请输入MESSAGE_TRACK_ID" allow-clear />
            </a-form-item>
            <a-form-item label="PROCESS_INSTANCE_ID：" name="processInstanceId">
                <a-input v-model:value="formData.processInstanceId" placeholder="请输入PROCESS_INSTANCE_ID" allow-clear />
            </a-form-item>
            <a-form-item label="WF_PROCESS_ID：" name="wfProcessId">
                <a-input v-model:value="formData.wfProcessId" placeholder="请输入WF_PROCESS_ID" allow-clear />
            </a-form-item>
            <a-form-item label="ACTIVITYINSTANCEID：" name="activityinstanceid">
                <a-input v-model:value="formData.activityinstanceid" placeholder="请输入ACTIVITYINSTANCEID" allow-clear />
            </a-form-item>
            <a-form-item label="ACTIVITYID：" name="activityid">
                <a-input v-model:value="formData.activityid" placeholder="请输入ACTIVITYID" allow-clear />
            </a-form-item>
            <a-form-item label="MESSAGE_STATE：" name="messageState">
                <a-input v-model:value="formData.messageState" placeholder="请输入MESSAGE_STATE" allow-clear />
            </a-form-item>
            <a-form-item label="XREF：" name="xref">
                <a-input v-model:value="formData.xref" placeholder="请输入XREF" allow-clear />
            </a-form-item>
            <a-form-item label="OVERTIME_STATUS：" name="overtimeStatus">
                <a-input v-model:value="formData.overtimeStatus" placeholder="请输入OVERTIME_STATUS" allow-clear />
            </a-form-item>
            <a-form-item label="SENDER_PERSON：" name="senderPerson">
                <a-input v-model:value="formData.senderPerson" placeholder="请输入SENDER_PERSON" allow-clear />
            </a-form-item>
            <a-form-item label="SENDER_PERSON_PARTYID：" name="senderPersonPartyid">
                <a-input v-model:value="formData.senderPersonPartyid" placeholder="请输入SENDER_PERSON_PARTYID" allow-clear />
            </a-form-item>
            <a-form-item label="SENDER_PERSON_CODE：" name="senderPersonCode">
                <a-input v-model:value="formData.senderPersonCode" placeholder="请输入SENDER_PERSON_CODE" allow-clear />
            </a-form-item>
            <a-form-item label="SENDER_DATE：" name="senderDate">
                <a-date-picker v-model:value="formData.senderDate" value-format="YYYY-MM-DD HH:mm:ss" show-time placeholder="请选择SENDER_DATE" style="width: 100%" />
            </a-form-item>
            <a-form-item label="UPDATED_DATE：" name="updatedDate">
                <a-date-picker v-model:value="formData.updatedDate" value-format="YYYY-MM-DD HH:mm:ss" show-time placeholder="请选择UPDATED_DATE" style="width: 100%" />
            </a-form-item>
            <a-form-item label="COMPLETED_DATE：" name="completedDate">
                <a-date-picker v-model:value="formData.completedDate" value-format="YYYY-MM-DD HH:mm:ss" show-time placeholder="请选择COMPLETED_DATE" style="width: 100%" />
            </a-form-item>
            <a-form-item label="PROCESSNAME：" name="processname">
                <a-input v-model:value="formData.processname" placeholder="请输入PROCESSNAME" allow-clear />
            </a-form-item>
            <a-form-item label="ACTIVITYNAME：" name="activityname">
                <a-input v-model:value="formData.activityname" placeholder="请输入ACTIVITYNAME" allow-clear />
            </a-form-item>
            <a-form-item label="OPERATE_NAME：" name="operateName">
                <a-input v-model:value="formData.operateName" placeholder="请输入OPERATE_NAME" allow-clear />
            </a-form-item>
            <a-form-item label="PERFORMER_NAME：" name="performerName">
                <a-input v-model:value="formData.performerName" placeholder="请输入PERFORMER_NAME" allow-clear />
            </a-form-item>
            <a-form-item label="PERFORMER_PARTYID：" name="performerPartyid">
                <a-input v-model:value="formData.performerPartyid" placeholder="请输入PERFORMER_PARTYID" allow-clear />
            </a-form-item>
            <a-form-item label="PERFORMER_CODE：" name="performerCode">
                <a-input v-model:value="formData.performerCode" placeholder="请输入PERFORMER_CODE" allow-clear />
            </a-form-item>
            <a-form-item label="TASK_STATUS：" name="taskStatus">
                <a-input v-model:value="formData.taskStatus" placeholder="请输入TASK_STATUS" allow-clear />
            </a-form-item>
            <a-form-item label="READ_STATUS：" name="readStatus">
                <a-input v-model:value="formData.readStatus" placeholder="请输入READ_STATUS" allow-clear />
            </a-form-item>
            <a-form-item label="DONE_STATUS：" name="doneStatus">
                <a-input v-model:value="formData.doneStatus" placeholder="请输入DONE_STATUS" allow-clear />
            </a-form-item>
            <a-form-item label="SUPPLY_STATUS：" name="supplyStatus">
                <a-input v-model:value="formData.supplyStatus" placeholder="请输入SUPPLY_STATUS" allow-clear />
            </a-form-item>
            <a-form-item label="MESSAGE_SOURCE：" name="messageSource">
                <a-input v-model:value="formData.messageSource" placeholder="请输入MESSAGE_SOURCE" allow-clear />
            </a-form-item>
            <a-form-item label="WF_MESSAGE_TYPE：" name="wfMessageType">
                <a-input v-model:value="formData.wfMessageType" placeholder="请输入WF_MESSAGE_TYPE" allow-clear />
            </a-form-item>
            <a-form-item label="IS_USABLE：" name="isUsable">
                <a-input v-model:value="formData.isUsable" placeholder="请输入IS_USABLE" allow-clear />
            </a-form-item>
            <a-form-item label="WF_MESSAGES_ATT1：" name="wfMessagesAtt1">
                <a-input v-model:value="formData.wfMessagesAtt1" placeholder="请输入WF_MESSAGES_ATT1" allow-clear />
            </a-form-item>
            <a-form-item label="WF_MESSAGES_ATT2：" name="wfMessagesAtt2">
                <a-input v-model:value="formData.wfMessagesAtt2" placeholder="请输入WF_MESSAGES_ATT2" allow-clear />
            </a-form-item>
            <a-form-item label="WF_MESSAGES_ATT3：" name="wfMessagesAtt3">
                <a-input v-model:value="formData.wfMessagesAtt3" placeholder="请输入WF_MESSAGES_ATT3" allow-clear />
            </a-form-item>
            <a-form-item label="WF_MESSAGES_ATT4：" name="wfMessagesAtt4">
                <a-input v-model:value="formData.wfMessagesAtt4" placeholder="请输入WF_MESSAGES_ATT4" allow-clear />
            </a-form-item>
            <a-form-item label="WF_MESSAGES_ATT5：" name="wfMessagesAtt5">
                <a-input v-model:value="formData.wfMessagesAtt5" placeholder="请输入WF_MESSAGES_ATT5" allow-clear />
            </a-form-item>
            <a-form-item label="SYS_PARTY_CODE：" name="sysPartyCode">
                <a-input v-model:value="formData.sysPartyCode" placeholder="请输入SYS_PARTY_CODE" allow-clear />
            </a-form-item>
            <a-form-item label="USABLE_STATUS：" name="usableStatus">
                <a-input v-model:value="formData.usableStatus" placeholder="请输入USABLE_STATUS" allow-clear />
            </a-form-item>
            <a-form-item label="CREATE_DATE：" name="createDate">
                <a-date-picker v-model:value="formData.createDate" value-format="YYYY-MM-DD HH:mm:ss" show-time placeholder="请选择CREATE_DATE" style="width: 100%" />
            </a-form-item>
            <a-form-item label="CREATE_IP：" name="createIp">
                <a-input v-model:value="formData.createIp" placeholder="请输入CREATE_IP" allow-clear />
            </a-form-item>
            <a-form-item label="CREATE_USER_ID：" name="createUserId">
                <a-input v-model:value="formData.createUserId" placeholder="请输入CREATE_USER_ID" allow-clear />
            </a-form-item>
            <a-form-item label="MODIFY_DATE：" name="modifyDate">
                <a-date-picker v-model:value="formData.modifyDate" value-format="YYYY-MM-DD HH:mm:ss" show-time placeholder="请选择MODIFY_DATE" style="width: 100%" />
            </a-form-item>
            <a-form-item label="MODIFY_IP：" name="modifyIp">
                <a-input v-model:value="formData.modifyIp" placeholder="请输入MODIFY_IP" allow-clear />
            </a-form-item>
            <a-form-item label="MODIFY_USER_ID：" name="modifyUserId">
                <a-input v-model:value="formData.modifyUserId" placeholder="请输入MODIFY_USER_ID" allow-clear />
            </a-form-item>
            <a-form-item label="ORDER_CODE：" name="orderCode">
                <a-input v-model:value="formData.orderCode" placeholder="请输入ORDER_CODE" allow-clear />
            </a-form-item>
            <a-form-item label="ATTRIBUTE1：" name="attribute1">
                <a-input v-model:value="formData.attribute1" placeholder="请输入ATTRIBUTE1" allow-clear />
            </a-form-item>
            <a-form-item label="ATTRIBUTE2：" name="attribute2">
                <a-input v-model:value="formData.attribute2" placeholder="请输入ATTRIBUTE2" allow-clear />
            </a-form-item>
            <a-form-item label="ATTRIBUTE3：" name="attribute3">
                <a-input v-model:value="formData.attribute3" placeholder="请输入ATTRIBUTE3" allow-clear />
            </a-form-item>
            <a-form-item label="ATTRIBUTE4：" name="attribute4">
                <a-input v-model:value="formData.attribute4" placeholder="请输入ATTRIBUTE4" allow-clear />
            </a-form-item>
            <a-form-item label="ATTRIBUTE5：" name="attribute5">
                <a-input v-model:value="formData.attribute5" placeholder="请输入ATTRIBUTE5" allow-clear />
            </a-form-item>
            <a-form-item label="IF_GETBACK：" name="ifGetback">
                <a-input v-model:value="formData.ifGetback" placeholder="请输入IF_GETBACK" allow-clear />
            </a-form-item>
            <a-form-item label="AUDIT_STEP_TYPE：" name="auditStepType">
                <a-input v-model:value="formData.auditStepType" placeholder="请输入AUDIT_STEP_TYPE" allow-clear />
            </a-form-item>
            <a-form-item label="COUNTERSIGN_LOGO：" name="countersignLogo">
                <a-input v-model:value="formData.countersignLogo" placeholder="请输入COUNTERSIGN_LOGO" allow-clear />
            </a-form-item>
            <a-form-item label="WF_AUTHORIZE_TYPE：" name="wfAuthorizeType">
                <a-input v-model:value="formData.wfAuthorizeType" placeholder="请输入WF_AUTHORIZE_TYPE" allow-clear />
            </a-form-item>
            <a-form-item label="WORKFLOW_ID：" name="workflowId">
                <a-input v-model:value="formData.workflowId" placeholder="请输入WORKFLOW_ID" allow-clear />
            </a-form-item>
            <a-form-item label="STEP_ID：" name="stepId">
                <a-input v-model:value="formData.stepId" placeholder="请输入STEP_ID" allow-clear />
            </a-form-item>
            <a-form-item label="SWITCHES：" name="switches">
                <a-input v-model:value="formData.switches" placeholder="请输入SWITCHES" allow-clear />
            </a-form-item>
            <a-form-item label="APPROVAL_USE_TIME：" name="approvalUseTime">
                <a-input v-model:value="formData.approvalUseTime" placeholder="请输入APPROVAL_USE_TIME" allow-clear />
            </a-form-item>
            <a-form-item label="SENDER_CUMAIL：" name="senderCumail">
                <a-input v-model:value="formData.senderCumail" placeholder="请输入SENDER_CUMAIL" allow-clear />
            </a-form-item>
            <a-form-item label="SENDER_OU：" name="senderOu">
                <a-input v-model:value="formData.senderOu" placeholder="请输入SENDER_OU" allow-clear />
            </a-form-item>
            <a-form-item label="PERFORMER_CUMAIL：" name="performerCumail">
                <a-input v-model:value="formData.performerCumail" placeholder="请输入PERFORMER_CUMAIL" allow-clear />
            </a-form-item>
            <a-form-item label="PERFORMER_OU：" name="performerOu">
                <a-input v-model:value="formData.performerOu" placeholder="请输入PERFORMER_OU" allow-clear />
            </a-form-item>
        </a-form>
        <template #footer>
            <a-button style="margin-right: 8px" @click="onClose">关闭</a-button>
            <a-button type="primary" @click="onSubmit" :loading="submitLoading">保存</a-button>
        </template>
    </a-drawer>
</template>

<script setup name="flwWorkflowMessagesForm">
    import { cloneDeep } from 'lodash-es'
    import { required } from '@/utils/formRules'
    import flwWorkflowMessagesApi from '@/api/biz/flwWorkflowMessagesApi'
    // 抽屉状态
    const visible = ref(false)
    const emit = defineEmits({ successful: null })
    const formRef = ref()
    // 表单数据
    const formData = ref({})
    const submitLoading = ref(false)

    // 打开抽屉
    const onOpen = (record) => {
        visible.value = true
        if (record) {
            let recordData = cloneDeep(record)
            formData.value = Object.assign({}, recordData)
        }
    }
    // 关闭抽屉
    const onClose = () => {
        formRef.value.resetFields()
        formData.value = {}
        visible.value = false
    }
    // 默认要校验的
    const formRules = {
    }
    // 验证并提交数据
    const onSubmit = () => {
        formRef.value
            .validate()
            .then(() => {
                submitLoading.value = true
                const formDataParam = cloneDeep(formData.value)
                flwWorkflowMessagesApi
                    .flwWorkflowMessagesSubmitForm(formDataParam, !formDataParam.workflowMessagesId)
                    .then(() => {
                        onClose()
                        emit('successful')
                    })
                    .finally(() => {
                        submitLoading.value = false
                    })
            })
    }
    // 抛出函数
    defineExpose({
        onOpen
    })
</script>
